package org.novelhibernate.support.dao;

import java.io.Serializable;
import java.sql.SQLException;



/**
 * This is a generic DAO that defines basic CRUD functions for a DAO 
 * (support for one PK only)
 * 
 * @author Tao Chen
 *
 * @param <T> type of entity
 * @param <ID> type of PK
 */

public interface GenericDAO <T, ID extends Serializable>{


	/**
	 * save an entity
	 * @param entity the target
	 * @param object any other parameters needed
	 * @throws any exception occurred
	 */
	public void save (T entity) throws SQLException, Throwable;
	
	/**
	 * save entities
	 * @param entity the targets
	 * @param object any other parameters needed
	 * @throws any exception occurred
	 */
	public void save (T[] entities) throws SQLException, Throwable;
	
	/**
	 * update an entity
	 * @param entity the target
	 * @param object any other parameters needed
	 * @throws any exception occurred
	 */
	public void update (T entity) throws SQLException, Throwable;
	
	/**
	 * update entities
	 * @param entity the targets
	 * @param object any other parameters needed
	 * @throws any exception occurred
	 */
	public void update (T[] entities) throws SQLException, Throwable;
	
	/**
	 * delete an entity
	 * @param entity the target
	 * @param object any other parameters needed
	 * @throws any exception occurred
	 */
	public void delete (T entity) throws SQLException, Throwable;
	
	/**
	 * delete entities
	 * @param entity the targets
	 * @param object any other parameters needed
	 * @throws any exception occurred
	 */
	public void delete (T[] entities) throws SQLException, Throwable;
	
	/**
	 * find an entity by ID
	 * @param entity the target
	 * @return the found entity
	 * @throws any exceptions occurred
	 */
	public T findById (ID id) throws RuntimeException;
	
	/**
	 * find entities by specific criteria
	 * @param filters the target criterias
	 * @param ids the id of target contact list, null means for all lists
	 * @return the found entities
	 * @throws any exceptions occurred
	 
	public List<T> search (Filter[] filters, String... ids) throws Throwable;
	*/
	
}

